import { Component, OnInit } from "@angular/core";
import * as ClassicEditor from "@ckeditor/ckeditor5-build-classic";

@Component({
  selector: "app-write-post",
  templateUrl: "./write-post.component.html",
  styleUrls: ["./write-post.component.scss"]
})

/**
 * 集成 CKEditor 来编辑内容。
 * @see https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/frameworks/angular.html
 */
export class WritePostComponent implements OnInit {
  //绑定到编辑器里的数据模型，里面可以带HTML标签
  public content = "";
  public Editor = ClassicEditor;

  constructor() {}

  ngOnInit(): void {}

  public onReady(editor: any) {
    editor.ui
      .getEditableElement()
      .parentElement.insertBefore(
        editor.ui.view.toolbar.element,
        editor.ui.getEditableElement()
      );
  }

  public doAddPost() {}
}
